import pytest
import requests

@pytest.fixture
def get_token():
    #用户登录
    url = "http://hn216.api.yesapi.cn/api/App/User/Login"
    data = {
        "app_key": "5F0F9C7ABF99DD714D484201C8A1A273",
        "username": "lgh",
        "password": "e10adc3949ba59abbe56e057f20f883e"
    }
    r = requests.post(url, data)
    dic = {}
    token = r.json().get("data").get("token")
    dic.setdefault("token", token)
    yield dic
    # 重新给会员设置分组以免 重复执行报错
    url_1 = "http://hn216.api.yesapi.cn/api/App/User/ChangeRole"
    data2 = {
        "app_key": "5F0F9C7ABF99DD714D484201C8A1A273",
        "other_uuid": "5DBCD41ACAEE5F56003BA5907BDCAEB5",
        "new_role": "setup组"
    }
    requests.post(url_1, data2)